if ( SERVER ) then
	function GM:ShowHelp() end
	function GM:OpenInfoScreen( ply )
		umsg.Start( "incursion.infoscreen", ply )
		umsg.End()
	end
	GM:AddHook( "ShowHelp", "OpenInfoScreen" )
	
	function GM:CommentCommand( ply, text, public )
		if ( string.lower( string.Left( text, 8 ) ) != "/comment" ) then return end
		if ( ( ply.NextComment or 0 ) > CurTime() ) then ply:ChatPrint( "Please wait before sending again." ) return "" end
		ply.NextComment = CurTime() + 10
		
		local current = file.Read( "comments.txt" ) or ""
			message = ply:Name() .. " / " .. ply:SteamID() .. " / " .. string.sub( text, 10 ) .. "\n"
		file.Write( "comments.txt", current .. message )
		
		ply:ChatPrint( "Thankyou for your comment." )		
		return ""
	end		
	GM:AddHook( "PlayerSay", "CommentCommand" )
end
if ( CLIENT ) then

local text = [[The object of this gamemode is to defend the generators from the invading NPCs.

Important keys:
Q/+menu: Open object spawn menu
C/+menu_context: Open weapon select/purchase menu
	
Disclaimer:
This is a WIP gamemode. Please treat it as such and realise that this is not the finished product.
Comments/criticism are appreciated and can be sent with the /comment chat command.
	
Press F1 to close this window.]]

local SFTR70 = Font( "SF TransRobotics", 70 )
local SFTR30 = Font( "SF TransRobotics", 30 )
local SFTR20B = Font( "Zekton Bold", 20, 700 )

local PANEL = {}
function PANEL:Init()
	self.Text = {}
	self.Open = true
end
function PANEL:SetOpen( bool )
	if ( bool == nil ) then bool = !self.Open end
	self.Open = bool
	self:SetVisible( self.Open )
end
function PANEL:SetText(text)
	self:PerformLayout()
	local maxW = self:GetWide() - 20
	
	self.Text = {}
	
	surface.SetFont(SFTR20B)
	local num = 1
	for _, line in ipairs(string.Explode("\n", text)) do
		local l = ""
		for _, word in ipairs(string.Explode(" ", line)) do
			local w = surface.GetTextSize(l .. word)
			if w > maxW then
				self.Text[num] = l
				num = num + 1
				l = ""
			end
			l = l .. word .. " "
		end
		self.Text[num] = l
		num = num + 1
	end
	
	self:PerformLayout()
end
function PANEL:PerformLayout()
	local w, h = 400, 100
	h = h + ( #self.Text * 18 ) + 10
	self:SetSize( w, h )
	self:SetPos( ScrH() * HUD_INSET, ( ScrH() * HUD_INSET * 2 ) + ( ScrH() * 0.09 ) )
end
function PANEL:Paint()
	local w, h = self:GetSize()
	
	surface.SetDrawColor( 40, 75, 125, 200 )
	surface.DrawRect( 0, 0, w, h )
	surface.SetDrawColor( 30, 55, 90, 200 )
	surface.DrawOutlinedRect( 0, 0, w, h )
	
	draw.SimpleText( "welcome to", SFTR30, 10, 10, HUD_TEXT_COLOUR )
	draw.SimpleText( "incursion", SFTR70, 40, 30, HUD_TEXT_COLOUR )
	
	local y = 100
	for _, line in pairs( self.Text ) do
		draw.SimpleText( line, SFTR20B, 10, y, HUD_TEXT_COLOUR )
		y = y + 18
	end
end
vgui.Register( "incursion.infoscreen", PANEL )

function GM:CreateInfoScreen()
	if self.InfoScreen then self.InfoScreen:Remove() end
	self.InfoScreen = vgui.Create( "incursion.infoscreen" )
	self.InfoScreen:SetText( text )
end
GM:AddHook( "Initialize", "CreateInfoScreen" )

local function OpenInfoScreen()
	if ( GAMEMODE.InfoScreen ) then GAMEMODE.InfoScreen:SetOpen() end
end
usermessage.Hook( "incursion.infoscreen", OpenInfoScreen )

end // End of CLIENT.